//
//  SYAccountTool.m
//  ChatDemo-UI2.0
//
//  Created by syun on 16/5/19.
//  Copyright © 2016年 syun. All rights reserved.
//

#import "SYAccountTool.h"
@implementation SYAccountTool

+(instancetype)ShareAccount
{
    static SYAccountTool *_tool;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        _tool = [[self alloc] init];
    });
    
    return _tool;
    
}

-(SYAccount *)account{

//    if (!_account || !_account.userid) {
    
    if (USERID) {
    
        NSDictionary *dic = [SyUserInfomation acquirePersonalImformationFromMemoryWithPersonID:USERID];
        NSDictionary *userinfoDic = [dic objectForKey:@"userinfo"];
        if (userinfoDic) {
            _account = [SYAccount mj_objectWithKeyValues:userinfoDic];
            
            _account.schoolnum = [[dic objectForKey:@"schoolnum"] intValue];
            //02.09 对学校管理员身份判断和信息存储,0代表不是学校管理员，大于0,代表是,该值为学校id
            _account.scname = [dic objectForKey:@"scname"];
            _account.schoolManage = [[dic objectForKey:@"schoolmanage"] intValue];
            _account.faceuserid = [[dic objectForKey:@"faceuserid"] integerValue];
            _account.haveclass = [[dic objectForKey:@"haveclass"] integerValue];
            _account.scid = [dic objectForKey:@"scid"];
           _account.facetype = [dic objectForKey:@"facetype"];
           
        }else
        {
            [self getUserInfoByID:USERID];
        }
        
    }else
    {
        [Utils alertViewWithMessage:@"请重新登陆!"];
    }

    
    return _account;
}
-(void)getUserInfoByID:(NSString *)userID
{
//    NSMutableDictionary *paramdic = [NSMutableDictionary dictionary];
//    [paramdic setObject:@"api_user_getinfobyid" forKey:@"Method"];
//    [paramdic setObject:userID forKey:@"userid"];
//    [Utils get:nil parameters:paramdic success:^(AFHTTPRequestOperation *operation, id jsonObject) {
//        
//        NSMutableDictionary *infomation = [jsonObject objectForKey:@"re_data"];
//        [SyUserInfomation personalImformationSaveWtih:infomation];
//    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        
//    }];
}

-(NSMutableArray *)receiveButNoAltArr{
    
    if (_receiveButNoAltArr == nil) {
        
        _receiveButNoAltArr = [[[NSUserDefaults standardUserDefaults] objectForKey:NORECEIVE] mutableCopy];
        
        if (_receiveButNoAltArr == nil) {
            
            _receiveButNoAltArr = [NSMutableArray array];
        }
    }
    
    return _receiveButNoAltArr;
}



@end
